// api_service.dart
import 'dart:convert';
import 'package:http/http.dart' as http;

class ApiService {
  // 公共的静态方法
  static Future<List<dynamic>> fetchJsonData(String url) async {
    final response = await http.get(Uri.parse(url));
    if (response.statusCode == 200) {
      // 检查内容类型
      // print(response.headers['content-type']);
      return json.decode(utf8.decode(response.bodyBytes));
    } else {
      throw Exception('Error al cargar datos');
    }
  }
}
